﻿using System;
using System.Collections.Generic;
using Abp.Runtime.Session;
using pandx.Mulan.DataImExPorting.Excel;
using pandx.Mulan.Dto;
using pandx.Mulan.Flow.FlowSchemes.Dto;
using pandx.Mulan.Storage;

namespace pandx.Mulan.Flow.FlowSchemes.Exporting;

public class FlowSchemeListExcelExporter:NpoiExcelExporterBase,IFlowSchemeListExcelExporter
{
    private readonly IAbpSession _abpSession;

    public FlowSchemeListExcelExporter(IAbpSession abpSession, ITempFileCacheManager tempFileCacheManager) : base(
        tempFileCacheManager)
    {
        _abpSession = abpSession;
    }

    public FileDto ExportToExcel(List<FlowSchemeListDto> flowSchemeListDtos)
    {
        return CreateExcelPackage("流程模板_" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + ".xlsx",
            excelPackage =>
            {
                var sheet = excelPackage.CreateSheet("流程模板");
                AddHeader(sheet,
                    "创建时间","流程模板名","表单模板描述","创建用户名","创建用户姓名"
                );
                AddObjects(sheet,2,flowSchemeListDtos,
                    _=>_.CreationTime,_=>_.SchemeName,_=>_.Description,_=>_.CreatorUserName,_=>_.CreatorName
                );
                for(var i=1;i<=flowSchemeListDtos.Count;i++)
                {
                    sheet.AutoSizeColumn(i);
                }
            });
    }
}